<template>
    <div class="form">
        <!-- <span  v-for="item in fromList">
            {{ item.label }}
        </span> -->
        <el-form>
            <el-form-item :label="item.label" v-for="item in fromList" :key="item.key">
                <el-input v-model="item.value" />
            </el-form-item>
        </el-form>
        <div class="btn">
            <el-button v-for="btn in btnList"  type="info" round :color="btn.color" @click="btnClick(btn.label)">
                {{btn.label}}
            </el-button>
        </div>

    </div>
</template>

<script setup lang="ts" >
import {FromInfo, BtnInfo} from '../../models/components/index'
interface Props {
    fromList: FromInfo[],
    btnList: BtnInfo[]
}
const props = defineProps<Props>()
const emit = defineEmits(['onClick', 'onChange', 'onInput'])

const btnClick = (label: string) => {
    const obj: { [key: string]: any } = props.fromList.reduce((acc, cur) => {
    if (cur.value && cur.key) {
            acc[cur.key] = cur.value;
        }
        return acc;
    }, {} as { [key: string]: any });
    emit('onClick', {label: label, value: obj})
}

</script>

<style scoped lang="css">
.form {
    color: #95979F;
    display: flex;
    justify-content: space-between;
    padding-right: 60px;
    /* display: flex; */
}
:deep(.el-form){
    display: flex;
}
:deep(.el-form-item){
    margin-left: 20px;
}
:deep(.el-input__inner) {
  border: 0;
  background: #000;
  border-radius: 8px;
  padding-left: 10px;
}
:deep(.el-input__wrapper) {
  padding: 0;
  border-radius: 10px;
}
:deep(.el-form-item__label) {
    color: #95979F;
}
:deep(.el-input__inner::placeholder) {
  color: #5E77D6;
  font-size: 14px;
  font-weight: 600;
}
</style>